package com.review.test;

import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;

public class test_01 {
    public static Map<Integer, Integer> numCount(List<Integer> list) {
        Map<Integer, Integer> map = new HashMap<>();
        for (Integer num : list) {
            if (!map.containsKey(num)) {
                map.put(num, 1);
            } else {
                map.put(num, map.get(num) + 1);
            }
        }
        return map;
    }

    public static void main(String[] args) {
        List<Integer> list = Arrays.asList(1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
        Map<Integer, Integer> numCount = numCount(list);
        for (Map.Entry<Integer, Integer> integerIntegerEntry : numCount.entrySet()) {
            System.out.println(integerIntegerEntry.getKey()+":"+integerIntegerEntry.getValue());
        }
        Set<Integer> integers = numCount.keySet();
        for (Integer integer : integers) {

        }
/*        CopyOnWriteArrayList<Integer> arrayList = new CopyOnWriteArrayList<>();
        arrayList.add(1);*/

/*        // List<Integer> list = new ArrayList<>();
        // List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        for (int i = list.size() - 1; i >= 0; i--) {
            if (list.get(i) % 2 == 0) {
                list.remove(i);
            }
        }
        *//*Iterator<Integer> iterator = list.iterator();
        while (iterator.hasNext()){
            if (iterator.next()%2==0){
                iterator.remove();
            }
        }*//*
        //list.removeIf(integer -> integer % 2 == 0);
        System.out.println(list);*/
    }
}
